package org.falco.SE4X;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Falco
 */
public class EconomyModel {

    private int currentRound;
    private List<Integer> carryOver;
    private List<Integer> colonies;
    private List<Integer> minerals;
    private List<Integer> pipe;
    private List<Integer> maintenance;
    private List<Integer> bid;
    private List<Integer> technology;
    private List<Integer> ship;
    private List<Integer> upgrades;
    private List<Integer> increase;
    private List<Integer> decrease;
    private List<Integer> roundResult;

    public EconomyModel() {
        carryOver = new ArrayList<Integer>();
        colonies = new ArrayList<Integer>();
        minerals = new ArrayList<Integer>();
        pipe = new ArrayList<Integer>();
        maintenance = new ArrayList<Integer>();
        bid = new ArrayList<Integer>();
        technology = new ArrayList<Integer>();
        ship = new ArrayList<Integer>();
        upgrades = new ArrayList<Integer>();
        increase = new ArrayList<Integer>();
        decrease = new ArrayList<Integer>();
        roundResult = new ArrayList<Integer>();
    }

    public int getRound() {
        return currentRound;
    }

    public int getLastRoundResult() {
        if (currentRound == 0) {
            return 0;
        } else {
            return roundResult.get(currentRound-1);
        }
    }

    public void nextRound() {
        processCurrentRound();
        currentRound++;
    }

    public void addCarryOver(int val) {
        carryOver.add(currentRound, val);
    }

    public void addColonies(int val) {
        colonies.add(currentRound, val);
    }

    public void addMinerals(int val) {
        minerals.add(currentRound, val);
    }

    public void addPipe(int val) {
        pipe.add(currentRound, val);
    }

    public void addMaintenance(int val) {
        maintenance.add(currentRound, val);
    }

    public void addBid(int val) {
        bid.add(currentRound, val);
    }

    public void addTechnology(int val) {
        technology.add(currentRound, val);
    }

    public void addShip(int val) {
        ship.add(currentRound, val);
    }

    public void addUpgrades(int val) {
        upgrades.add(currentRound, val);
    }

    public void addIncrease(int val) {
        increase.add(currentRound, val);
    }

    public void addDecrease(int val) {
        decrease.add(currentRound, val);
    }

    private void processCurrentRound() {
        //TODO make check on mandatory fields
        roundResult.add(currentRound,
                carryOver.get(currentRound)
                + colonies.get(currentRound)
                + minerals.get(currentRound)
                + pipe.get(currentRound)
                - maintenance.get(currentRound)
                - bid.get(currentRound)
                - technology.get(currentRound)
                - ship.get(currentRound)
                - upgrades.get(currentRound));
    }
}
